package com.treasure.common.model;

import com.treasure.common.types.InteractionId;
import lombok.Data;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * @author sunhongmin
 * @date 2023/9/6 22:44
 * @description
 */
@Data
public class ChatHistoryEntity {

    /**
     * 交互历史ID
     */
    private InteractionId interactionId;

    /**
     * 问-答 trace链
     */
    private String trace;

    /**
     * 聊天记录
     */
    private List<ChatHistoryBean> chatHistoryBeans;

    public void addChatHistory(ChatHistoryBean chatHistoryBean) {
        if (Objects.isNull(chatHistoryBeans)) {
            chatHistoryBeans = new ArrayList<>();
        }
        chatHistoryBeans.add(chatHistoryBean);
    }

    @Data
    public static class ChatHistoryBean {
        /**
         * 标识
         */
        private String iden;
        /**
         * 消息
         */
        private String message;
    }

    public enum IdenEnum {
        SYS("system"), // messages[0]中支持role为system
        USER("user"),
        ASSISTANT("assistant");

        @Getter
        private final String value;

        IdenEnum(String value) {
            this.value = value;
        }
    }
}
